<?php
//模型
class ChuxingModel extends MY_Model {
	function __construct(){
		parent::__construct();
		$this->table = 'm_chuxing';
	}
	
	function get_list($arr,$page=1,$size=10){
		$where = ' 1 ';
		
		if(isset($arr['chepai']) && !empty($arr['chepai'])){
			$where .= " AND cp.chepai like '%{$arr['chepai']}%'";
		}
		
		if(isset($arr['start_time']) && !empty($arr['start_time']) && isset($arr['end_time']) && !empty($arr['end_time'])){
			$where .= " AND date >'{$arr['start_time']}' AND date <='{$arr['end_time']}' ";
		}
		
		
		$join = " left join ".$this->db->dbprefix."user as u ON u.id = cp.user_id ";
		$res = $this->_where_get_list($where,$page,$size,"order by id desc","cp.*,u.nickname as user_name","cp",$join);
		return $res;
	}
	
	function get_info($id){
		$sql  = "select * from ".$this->db->dbprefix.$this->table." where id='{$id}' limit 1";
		$query = $this->db->query($sql);
		$row = $query->row_array();
		return $row;
	}
	
	
}

